package com.sl.ms.trade.handler.wechat.response;

import lombok.Data;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author wjh
 * @create 2023-09-22 22:31
 */
@Data
public class WeChatResponse {
    private int status; //响应状态码
    private String body; //响应体数据

    public WeChatResponse() {

    }
    
    public WeChatResponse(CloseableHttpResponse response) {
        this.status = response.getStatusLine().getStatusCode();
        try {
            this.body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            
        }
        
    }
    public Boolean isOk() {
        return this.status == 200;
    }
}
